package com.station.job;

import com.station.service.BasicDataService;
import com.station.service.CommonPayRecordService;
import com.station.service.PurchaseDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class BldWorker {
    @Autowired
    private CommonPayRecordService commonPayRecordService;
    @Autowired
    private BasicDataService basicDataService;
    @Autowired
    private PurchaseDataService purchaseDataService;


    //@Scheduled(cron = "0 30 0 * * ?")  // 每天凌晨12点半执行
    private void checkMaterial(){
        log.info("================定时任务开始执行======================");
        //刷新计量单位
        basicDataService.batchSyncUnit();
        log.info("================定时任务开始执行结束==================");
    }

    public void syncSaleOrder(){
        log.info("================销售订单数据同步定时任务开始执行======================");

        log.info("================销售订单数据同步定时任务开始执行结束==================");
    }

    //@Scheduled(cron = "0 30 0 * * ?")  // 每天凌晨12点半执行
    private void syncPurchase(){
        log.info("================定时任务开始执行======================");
        //同步采购订单
        purchaseDataService.batchSyncPurchase(null,null, null);
        log.info("================定时任务开始执行结束==================");
    }

    //@Scheduled(cron = "0 30 0 * * ?")  // 每天凌晨12点半执行
    private void syncInStockRequest(){
        log.info("================定时任务开始执行======================");
        //同步采购入库单
        purchaseDataService.batchSyncInStock(null,null);
        log.info("================定时任务开始执行结束==================");
    }

    //@Scheduled(cron = "0 30 0 * * ?")  // 每天凌晨12点半执行
    private void syncPayBillRequest(){
        log.info("================定时任务开始执行======================");
        //批量同步付款单
        purchaseDataService.batchSyncPayBill(null,null);
        log.info("================定时任务开始执行结束==================");
    }
}
